abstract class Handler {
    successor: Handler;
    setSuccessor(successor: Handler): void {
        this.successor = successor;
    }
    handleRequest(request:string) {
        if (this.successor) {
            this.successor.handleRequest(request);
        }
    }
}

class ConcreteHandler extends Handler {
    type: string;
    constructor(type: string) {
        super();
        this.type = type;
    }
    handleRequest(request:string) {
        if (this.type === request) {
            console.log('process type', this.type);
        } else {
            super.handleRequest(request);
        }
    }
}

const a  = new ConcreteHandler('a');
const b  = new ConcreteHandler('b');
const c  = new ConcreteHandler('c');
a.setSuccessor(b);
b.setSuccessor(c);
a.handleRequest('c');

